//
//  YTMyGLYTableViewCell.m
//  YuTang
//
//  Created by 葛悦彣 on 2024/8/14.
//

#import "YTMyGLYTableViewCell.h"
@interface YTMyGLYTableViewCell ()
@property (nonatomic ,strong) UILabel * warehouse;
@property (nonatomic ,strong) UILabel * template;
@property (nonatomic ,strong) UILabel * user;
@end
@implementation YTMyGLYTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setupView];
    }
    return self;
}


- (void)setupView{
    
    self.backgroundColor = UIColor.clearColor;
    self.contentView.backgroundColor = UIColor.clearColor;
    self.contentView.clipsToBounds = YES;
    self.userInteractionEnabled = YES;
    self.contentView.userInteractionEnabled = YES;
    
    MJWeakSelf
    UIView * ckview = [UIView new];
    ckview.addClickBlock(^{
        [weakSelf openCK];
    });
    ckview.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:ckview];
    [DTKTool YJYY:kwt(5) andView:ckview andWidth:1 andColor:KcolorHex(@"#E6E6E6") andSize:CGSizeMake(0,1) andOpacity:0.5];
    [ckview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(8));
        make.top.offset(0);
        make.width.offset(kwt(175));
        make.height.offset(kwt(160));
    }];
    
    UILabel * templab1 = [DTKTool labelWithText:@"仓库管理" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
    [ckview addSubview:templab1];
    [templab1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(14));
        make.top.offset(kwt(15));
    }];
    
    UILabel * templab2 = [DTKTool labelWithText:@"预警数量" andFont:kFont(15) andTextColor:KcolorHex(@"#8D8D8D")];
    [ckview addSubview:templab2];
    [templab2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(14));
        make.top.offset(kwt(43));
    }];

    UILabel * warehouse = [DTKTool labelWithText:@"0" andFont:kFont(15) andTextColor:KcolorHex(@"#8D8D8D")];
    self.warehouse = warehouse;
    [ckview addSubview:warehouse];
    [warehouse mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(templab2.mas_right).offset(kwt(5));
        make.centerY.equalTo(templab2);
    }];

    UIImageView * ckimg = kimageView(@"warehouse_management");
    [ckview addSubview:ckimg];
    [ckimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(kwt(83));
        make.bottom.offset(kwt(-3));
        make.right.offset(kwt(-2));
    }];

    UIView * ryview = [UIView new];
    ryview.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:ryview];
    [DTKTool YJYY:kwt(5) andView:ryview andWidth:1 andColor:KcolorHex(@"#E6E6E6") andSize:CGSizeMake(0,1) andOpacity:0.5];
    [ryview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(190));
        make.top.offset(0);
        make.right.offset(kwt(-8));
        make.height.offset(kwt(75));
    }];
    ryview.addClickBlock(^{
        [weakSelf openRY];
    });
    UIImageView * ryimg = kimageView(@"personnel_management");
    [ryview addSubview:ryimg];
    [ryimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(kwt(55));
        make.centerY.offset(0);
        make.left.offset(kwt(5));
    }];
    UILabel * templab3 = [DTKTool labelWithText:@"人员管理" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
    [ryview addSubview:templab3];
    [templab3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(68));
        make.top.offset(kwt(15));
    }];
    UILabel * user = [DTKTool labelWithText:@"0位人员" andFont:kFont(15) andTextColor:KcolorHex(@"#8D8D8D")];
    self.user = user;
    [ryview addSubview:user];
    [user mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(68));
        make.top.offset(kwt(43));
    }];
    
    UIView * mbview = [UIView new];
    mbview.backgroundColor = UIColor.whiteColor;
    [self.contentView addSubview:mbview];
    [DTKTool YJYY:kwt(5) andView:mbview andWidth:1 andColor:KcolorHex(@"#E6E6E6") andSize:CGSizeMake(0,1) andOpacity:0.5];
    [mbview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(190));
        make.top.equalTo(ryview.mas_bottom).offset(kwt(8));
        make.right.offset(kwt(-8));
        make.height.offset(kwt(75));
    }];
    mbview.addClickBlock(^{
        [weakSelf openMB];
    });
    UIImageView * mbimg = kimageView(@"template _management");
    [mbview addSubview:mbimg];
    [mbimg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.offset(kwt(55));
        make.centerY.offset(0);
        make.left.offset(kwt(5));
    }];
    UILabel * templab4 = [DTKTool labelWithText:@"模板管理" andFont:kCFont(18) andTextColor:KcolorHex(@"#222222")];
    [mbview addSubview:templab4];
    [templab4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(68));
        make.top.offset(kwt(15));
    }];
    UILabel * template = [DTKTool labelWithText:@"0" andFont:kFont(15) andTextColor:KcolorHex(@"#8D8D8D")];
    self.template = template;
    [mbview addSubview:template];
    [template mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(kwt(68));
        make.top.offset(kwt(43));
    }];
}
- (void)setModel:(YTMyModel *)model{
    _model = model;
    self.template.text = [NSString stringWithFormat:@"%lu个模版",model.Template];
    self.user.text = [NSString stringWithFormat:@"%lu位人员",model.user];
    self.warehouse.text = [NSString stringWithFormat:@"%lu",model.warehouse];
}
- (void)openCK{
    if(self.openCKBlock){
        self.openCKBlock();
    }
}

- (void)openRY{
    if(self.openRYBlock){
        self.openRYBlock();
    }
}

- (void)openMB{
    if(self.openMBBlock){
        self.openMBBlock();
    }
}
@end
